
import storage from '../../util/storage.js'

export default {
  state: {
    SYS_PARAMS:  storage.local.get('SYS_PARAMS') || {}, //系统功能码对照表
    token: storage.local.get('token'),
    userInfo: {},
    productInfo:  storage.local.get('productInfo') || {},
    gateway: {},
  },
  mutations: {
    SET_SYS_PARAMS(state, data) {
      state.SYS_PARAMS = data;
      storage.local.set('SYS_PARAMS', data)
    },
    SET_TOKEN(state, data){
      state.token = data;
      storage.local.set('token', token);
    },
    SET_PRODUCT_INFO(state, data){
      state.productInfo = data;
      storage.local.set('productInfo', data);
    },
    SET_GATEWAY(state, data){
      state.gateway = data;
      // storage.local.set('gatewayInfo', data);
    },
    SET_USER_INFO(state, data){
      state.userInfo = data;
      storage.local.set('userInfo', data);
    }
  },
  actions: {
    // 设置分页大小
    SET_SYS_PARAMS({ commit }, data) {
      commit('SET_SYS_PARAMS', data)
    },
    SET_TOKEN({ commit }, data) {
      commit('SET_TOKEN', data)
    },
    SET_PRODUCT_INFO({ commit }, data) {
      commit('SET_PRODUCT_INFO', data)
    },
    SET_GATEWAY({ commit }, data) {
      commit('SET_GATEWAY', data)
    },
    SET_USER_INFO({ commit }, data){
      commit('SET_USER_INFO', data)
    }
  }
}
